package com.starinside.wp.domain;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.starinside.wp.foundation.vo.BindedBabyVO;
import com.starinside.wp.utils.EmojiUtils;
import lombok.Data;
import me.chanjar.weixin.mp.bean.result.WxMpUser;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;

@Entity
@Data
@Table(name = "wx_user")
public class WxUser extends Domain{

    @Column(name = "nickname")
    private String nickName;

    @Column(name = "sex_desc")
    private String sexDesc;

    @Column
    private Integer sex=0;

    @Column
    private String language;

    @Column
    private String city;

    @Column
    private String province;

    @Column
    private String country;

    @Column(name = "head_img_url")
    private String headImgUrl;

    @Column
    @Deprecated
    private String openid;

    @Column
    private String unionid;

    @Column(name = "openid_wp")
    private String openidWp;

    @Column
    private String session_key;

    @Column
    private Boolean subscribe=false;

    @Column(name = "subscribe_time")
    private Long subscribeTime;

    @Column(name = "parent_mobile")
    private String parentMobile;

    @Column(name = "parent_id")
    private String parentId;

    @Column(name = "default_baby")
    private String defaultBabyId;

    @Column(name = "remark")
    private String remark;

    @Column(name = "source_appid", columnDefinition = "varchar(32) COMMENT '来源appid'")
    private String sourceAppId;

    @JsonInclude()
    @Transient
    private BindedBabyVO defaultBaby;

    @JsonInclude()
    @Transient
    private boolean liveroomValid;

    @Transient
    private String ticket;

    public void setEntries(WxMpUser mpUser){
        this.nickName = mpUser.getNickname();
        this.sexDesc = mpUser.getSexDesc();
        this.sex = mpUser.getSex();
        this.language = mpUser.getLanguage();
        this.city = mpUser.getCity();
        this.province = mpUser.getProvince();
        this.country = mpUser.getCountry();
        this.headImgUrl = mpUser.getHeadImgUrl();
        this.unionid = mpUser.getUnionId();
        this.openidWp = mpUser.getOpenId();
        this.remark = mpUser.getRemark();
    }
}
